<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<c:set var="subMenuId" value="1" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="css/left.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.6.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
	function logout(){
		if(window.parent!=null){
			window.parent.location="${ctx}/logout.htm";
		}else{
			window.location="${ctx}/logout.htm";
		}		
	}
</script>
</head>
<body
	style="margin: 0; padding: 0; overflow-x: hidden; overflow-y: auto">
	<div class="left">
		<div class="welcome">
			<div id="ninhao">
				您好，${adminUser.adminName }<br> <a href="" onclick="logout();">退出系统</a>
			</div>
		</div>
		<div class="left_center" id="left_center">
			<div class="left_body">
				<dl id="menu">
					<c:forEach var="resource" step="1" items="${adminUser.menuList}" varStatus="status">					
                    <dt>
                    <c:if test="${resource.resourceUrl!=null && resource.resourceUrl!=''}">
						<a href="${ctx}${resource.resourceUrl}" target="mainFrame">${resource.resourceName}</a>
					</c:if>
					<c:if test="${resource.resourceUrl==null || resource.resourceUrl==''}">
					<a href="javascript:void(0)">${resource.resourceName}</a>
					</c:if>
                    </dt>
                    <dd>
                    	<c:if test="${adminUser.subMenu[resource.resourceId]!=null}">
                    		<c:forEach var="subMenu" step="1"
								items="${adminUser.subMenu[resource.resourceId]}" varStatus="ss">                    		                    
                        	<h2>
                        	<c:if test="${subMenu.resourceUrl!=null && subMenu.resourceUrl!=''}">
                        		<a href="${ctx}${subMenu.resourceUrl}"  target="mainFrame">${subMenu.resourceName}</a>
                        	</c:if>
                        	<c:if test="${subMenu.resourceUrl==null || subMenu.resourceUrl==''}">
								<a href="javascript:void(0)">${subMenu.resourceName}</a>
							</c:if>
                        	</h2>
                 			<ul>
                 				<c:forEach var="childMenu" step="1"
								items="${adminUser.subMenu[subMenu.resourceId]}" varStatus="dd">                   			
               						<a href="${ctx}${childMenu.resourceUrl}"  target="mainFrame">${childMenu.resourceName}</a>
               					</c:forEach>                        
                        	</ul>  
                        	</c:forEach>
                        </c:if>                   
                    </dd>
                   </c:forEach>                    
                </dl>
            </div>
				
			<div class="left_bodybot"></div>
		</div>
	</div>
</body>
<script>
		$(function(){			
			//让所有的<a>隐藏点击时的虚线
			$("a").attr("hidefocus","hidefocus");			
			
			//1 左侧底部背景自动在底部，且不影响上面面板 开始
			var windowheight=$(window).height();//窗口的高度
			var leftheight=windowheight-80;//窗口的高度减去欢迎块的高度
			$(".left_center").css("height",leftheight);//动态设置left_center的高度
			//1 左侧底部背景自动在底部，且不影响上面面板 结束
			
			//2 右边frame高度动态设置为刚好满屏 开始
			var leftheight=$(".left_center").height();
			var maindoc=window.parent.frames["centerFrame"].document;
			$(maindoc).find("#mainFrame").css("height",leftheight+44);
			//2 右边frame高度动态设置为刚好满屏 结束
						
			//当窗口缩放时以上两种情况自适应
			window.onresize=function(){
				//1 情况
				var windowheight=$(window).height();//窗口的高度
				var leftheight=windowheight-80;//窗口的高度减去欢迎块的高度
				$(".left_center").css("height",leftheight);//动态设置left_center的高度
				
				//2 情况
				var maindoc=window.parent.frames["centerFrame"].document;
				$(maindoc).find("#mainFrame").css("height",leftheight+44);
				
				//3 情况
				//获取id为reportViewPanel的iframe 		
				var reportViewPanel=maindoc.getElementById("mainFrame").contentWindow.document.getElementById("reportViewPanel");
				if(reportViewPanel!=null&&reportViewPanel!=undefined)
					{
						var leftheight=$(".left_center").height();
						//由左侧距离及iframe顶部所有高度计算reportViewPanel这一iframe的高度
						$(reportViewPanel).css("height",leftheight-40);
					}
				};
			
			});	
    </script>

	<script language="JavaScript">
		(function(){						
			function $Id(Id){return document.getElementById(Id);}
			function $Tag(id,Tag){return id.getElementsByTagName(Tag);}
			function getNextNode(node){
				if (!node.nodeType) {
					return false;
				}
				// 取得元素的下一个节点
				var node = node.nextSibling;
				// 帅选元素的下一个元素节点
				for (; node; node = node.nextSibling) {
					if (node.nodeType === 1) {
						return node;
					}
				}
			}
			function ShowMenu(e){
				var $dt = $Tag($Id(e),"dt");
				var $dd = $Tag($Id(e),"dd");
				var mainhtml=window.parent.frames["centerFrame"];
				for(var t=0;t<$dt.length;t++){
					var $h2 = $Tag($dd[t],"h2");
					var $ul = $Tag($dd[t],"ul");
					$dt[t].value=t;
					$dt[t].onclick = function(){
						ShowClose(this,this.value);
						//设置一级导航开始
						var listguide= $Tag(this, "a")[0].innerHTML;
						//var mapstr="宝贝购数据报表系统 >> "+"<span style='color:#002D61;' class='firstguide'>"+ listguide+"</span>" + "<span style='color:#002D61;' class='secguide'></span>" + "<span style='color:#002D61;' class='thirdguide'></span>";
						//mainhtml.document.getElementById("guide").innerHTML=mapstr;
						//设置一级导航结束 
					};
					for(var h=0;h<$h2.length;h++){
						$h2[h].value=h;
						$h2[h].onclick = function(){
							// 设置二级菜单
							var secguide = $Tag(this, "a")[0].innerHTML;
							var guideElement = mainhtml.document.getElementById("guide");
							var secspan = $Tag(guideElement, "span");
							secspan[1].innerHTML = " >> " + secguide;
							secspan[2].innerHTML = "";
							ShowClose(this,this.value); 
							var ulNode = getNextNode(this); 
							// if(ulNode.offsetHeight > 150) ulNode.style.height = "150px" 
							};
							// 取出所有的三级菜单
							var $items = $Tag(getNextNode($h2[h]),"a");
							for(var m=0; m<$items.length;m++){
								$items[m].onclick= function(){
									$Tag(mainhtml.document.getElementById("guide"), "span")[2].innerHTML = " >> " + this.innerHTML;
								};
							}
					}
				}
				function ShowClose(obj,n){
					var dt = $Tag(obj.parentNode,obj.tagName);
					var dd = $Tag(obj.parentNode,[obj.parentNode.tagName!="DL"?"ul":"dd"]);
					if(dd.length==0 || !dd[n]){return false;}
					if(dd[n].style.display == "block"){
						obj.className = "";
						dd[n].style.display = "none";
						return false;
					}
					for(var i=0;i<dt.length;i++){
						dt[i].className=[i!=n?"":"off"];
					}
					for(var i=0;i<dd.length;i++){dd[i].style.display=[i!=n?"none":"block"];}
				}
			}
			//new ShowMenu( "menu");						
		}());
	</script>
</html>
